package com.zhoumy.study.java8;

import org.junit.Test;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;

/**
 * @author: zhoumy
 * @create: 2024年6月12日18:59:01
 */
public class TestLambda {

    //原来的匿名内部类
    @Test
    public void test1() {
        //原来的匿名内部类
        Comparator<Integer> comparator = new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return Integer.compare(o1, o2);
            }
        };
        TreeSet<Integer> ts = new TreeSet<>(comparator);
    }

    //Lambda表达式
    @Test
    public void test2() {

        Comparator<Integer> comparator = (x, y) -> Integer.compare(x, y);

        TreeSet<Integer> ts = new TreeSet<>(comparator);
    }


    List<Employee> employeeLists = Arrays.asList(
            new Employee("张三", 18, 3333),
            new Employee("李四", 38, 55555),
            new Employee("王五", 50, 6666.66),
            new Employee("赵六", 16, 77777.77),
            new Employee("田七", 8, 8888.88)
    );

    //

}
